/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package membershipdemo;

import KatebaUtil.KatebaUtil;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author labib.farag
 */
@Entity
@Table(name = "members", catalog = "membership_affairs", schema = "")
@NamedQueries({
    @NamedQuery(name = "Members.findAll", query = "SELECT m FROM Members m"),
    @NamedQuery(name = "Members.findById", query = "SELECT m FROM Members m WHERE m.id = :id"),
    @NamedQuery(name = "Members.findByMemId", query = "SELECT m FROM Members m WHERE m.memId = :memId"),
    @NamedQuery(name = "Members.findByMemName", query = "SELECT m FROM Members m WHERE m.memName = :memName"),
    @NamedQuery(name = "Members.findByDateOfBirth", query = "SELECT m FROM Members m WHERE m.dateOfBirth = :dateOfBirth"),
    @NamedQuery(name = "Members.findByPlaceOfBirth", query = "SELECT m FROM Members m WHERE m.placeOfBirth = :placeOfBirth"),
    @NamedQuery(name = "Members.findByNatId", query = "SELECT m FROM Members m WHERE m.natId = :natId"),
    @NamedQuery(name = "Members.findByDateOfNatId", query = "SELECT m FROM Members m WHERE m.dateOfNatId = :dateOfNatId"),
    @NamedQuery(name = "Members.findByCurrentJob", query = "SELECT m FROM Members m WHERE m.currentJob = :currentJob"),
    @NamedQuery(name = "Members.findByJobDegree", query = "SELECT m FROM Members m WHERE m.jobDegree = :jobDegree"),
    @NamedQuery(name = "Members.findByHireDate", query = "SELECT m FROM Members m WHERE m.hireDate = :hireDate"),
    @NamedQuery(name = "Members.findByAddress", query = "SELECT m FROM Members m WHERE m.address = :address"),
    @NamedQuery(name = "Members.findByJoiningDate", query = "SELECT m FROM Members m WHERE m.joiningDate = :joiningDate"),
    @NamedQuery(name = "Members.findByDeductionDate", query = "SELECT m FROM Members m WHERE m.deductionDate = :deductionDate"),
    @NamedQuery(name = "Members.findByWorkPlace", query = "SELECT m FROM Members m WHERE m.workPlace = :workPlace"),
    @NamedQuery(name = "Members.findByDateOfAnnouncement", query = "SELECT m FROM Members m WHERE m.dateOfAnnouncement = :dateOfAnnouncement"),
    @NamedQuery(name = "Members.findByHomePhone", query = "SELECT m FROM Members m WHERE m.homePhone = :homePhone"),
    @NamedQuery(name = "Members.findByMobile", query = "SELECT m FROM Members m WHERE m.mobile = :mobile"),
    @NamedQuery(name = "Members.findByEducation", query = "SELECT m FROM Members m WHERE m.education = :education"),
    @NamedQuery(name = "Members.findByEmail", query = "SELECT m FROM Members m WHERE m.email = :email"),
    @NamedQuery(name = "Members.findByImagePath", query = "SELECT m FROM Members m WHERE m.imagePath = :imagePath")})
public class Members implements Serializable {

    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "id")
    private int id;
    @Id
    @Basic(optional = false)
    @Column(name = "mem_id")
    private Integer memId;
    @Basic(optional = false)
    @Column(name = "mem_name")
    private String memName;
    @Basic(optional = false)
    @Column(name = "date_of_birth")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfBirth;
    @Basic(optional = false)
    @Column(name = "place_of_birth")
    private String placeOfBirth;
    @Basic(optional = false)
    @Column(name = "nat_id")
    private long natId;
    @Basic(optional = false)
    @Column(name = "date_of_nat_id")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfNatId;
    @Basic(optional = false)
    @Column(name = "current_job")
    private String currentJob;
    @Basic(optional = false)
    @Column(name = "job_degree")
    private String jobDegree;
    @Basic(optional = false)
    @Column(name = "hire_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date hireDate;
    @Basic(optional = false)
    @Column(name = "address")
    private String address;
    @Basic(optional = false)
    @Column(name = "joining_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date joiningDate;
    @Basic(optional = false)
    @Column(name = "deduction_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date deductionDate;
    @Basic(optional = false)
    @Column(name = "work_place")
    private String workPlace;
    @Basic(optional = false)
    @Column(name = "date_of_announcement")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfAnnouncement;
    @Basic(optional = false)
    @Column(name = "home_phone")
    private String homePhone;
    @Basic(optional = false)
    @Column(name = "mobile")
    private String mobile;
    @Basic(optional = false)
    @Column(name = "education")
    private String education;
    @Basic(optional = false)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @Column(name = "image_path")
    private String imagePath;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "memId")
    private List<Subvention> subventionList;

    public Members() {
    }

    public Members(Integer memId) {
        this.memId = memId;
    }

    public Members(Integer memId, int id, String memName, Date dateOfBirth, String placeOfBirth, long natId, Date dateOfNatId, String currentJob, String jobDegree, Date hireDate, String address, Date joiningDate, Date deductionDate, String workPlace, Date dateOfAnnouncement, String homePhone, String mobile, String education, String email, String imagePath) {
        this.memId = memId;
        this.id = id;
        this.memName = memName;
        this.dateOfBirth = dateOfBirth;
        this.placeOfBirth = placeOfBirth;
        this.natId = natId;
        this.dateOfNatId = dateOfNatId;
        this.currentJob = currentJob;
        this.jobDegree = jobDegree;
        this.hireDate = hireDate;
        this.address = address;
        this.joiningDate = joiningDate;
        this.deductionDate = deductionDate;
        this.workPlace = workPlace;
        this.dateOfAnnouncement = dateOfAnnouncement;
        this.homePhone = homePhone;
        this.mobile = mobile;
        this.education = education;
        this.email = email;
        this.imagePath = imagePath;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        int oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public Integer getMemId() {
        return memId;
    }

    public void setMemId(Integer memId) {
        Integer oldMemId = this.memId;
        this.memId = memId;
        changeSupport.firePropertyChange("memId", oldMemId, memId);
    }

    public String getMemName() {
        return memName;
    }

    public void setMemName(String memName) {
        String oldMemName = this.memName;
        this.memName = memName;
        changeSupport.firePropertyChange("memName", oldMemName, memName);
    }

    public Date getDateOfBirth() {
        return dateOfBirth;
    }

    public void setDateOfBirth(Date dateOfBirth) {
        Date oldDateOfBirth = this.dateOfBirth;
        this.dateOfBirth = dateOfBirth;
        changeSupport.firePropertyChange("dateOfBirth", oldDateOfBirth, dateOfBirth);
    }

    public String getPlaceOfBirth() {
        return placeOfBirth;
    }

    public void setPlaceOfBirth(String placeOfBirth) {
        String oldPlaceOfBirth = this.placeOfBirth;
        this.placeOfBirth = placeOfBirth;
        changeSupport.firePropertyChange("placeOfBirth", oldPlaceOfBirth, placeOfBirth);
    }

    public long getNatId() {
        return natId;
    }

    public void setNatId(long natId) {
        long oldNatId = this.natId;
        this.natId = natId;
        changeSupport.firePropertyChange("natId", oldNatId, natId);
    }

    public Date getDateOfNatId() {
        return dateOfNatId;
    }

    public void setDateOfNatId(Date dateOfNatId) {
        Date oldDateOfNatId = this.dateOfNatId;
        this.dateOfNatId = dateOfNatId;
        changeSupport.firePropertyChange("dateOfNatId", oldDateOfNatId, dateOfNatId);
    }

    public String getCurrentJob() {
        return currentJob;
    }

    public void setCurrentJob(String currentJob) {
        String oldCurrentJob = this.currentJob;
        this.currentJob = currentJob;
        changeSupport.firePropertyChange("currentJob", oldCurrentJob, currentJob);
    }

    public String getJobDegree() {
        return jobDegree;
    }

    public void setJobDegree(String jobDegree) {
        String oldJobDegree = this.jobDegree;
        this.jobDegree = jobDegree;
        changeSupport.firePropertyChange("jobDegree", oldJobDegree, jobDegree);
    }

    public Date getHireDate() {
        return hireDate;
    }

    public void setHireDate(Date hireDate) {
        Date oldHireDate = this.hireDate;
        this.hireDate = hireDate;
        changeSupport.firePropertyChange("hireDate", oldHireDate, hireDate);
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        String oldAddress = this.address;
        this.address = address;
        changeSupport.firePropertyChange("address", oldAddress, address);
    }

    public Date getJoiningDate() {
        return joiningDate;
    }

    public void setJoiningDate(Date joiningDate) {
        Date oldJoiningDate = this.joiningDate;
        this.joiningDate = joiningDate;
        changeSupport.firePropertyChange("joiningDate", oldJoiningDate, joiningDate);
    }

    public Date getDeductionDate() {
        return deductionDate;
    }

    public void setDeductionDate(Date deductionDate) {
        Date oldDeductionDate = this.deductionDate;
        this.deductionDate = deductionDate;
        changeSupport.firePropertyChange("deductionDate", oldDeductionDate, deductionDate);
    }

    public String getWorkPlace() {
        return workPlace;
    }

    public void setWorkPlace(String workPlace) {
        String oldWorkPlace = this.workPlace;
        this.workPlace = workPlace;
        changeSupport.firePropertyChange("workPlace", oldWorkPlace, workPlace);
    }

    public Date getDateOfAnnouncement() {
        return dateOfAnnouncement;
    }

    public void setDateOfAnnouncement(Date dateOfAnnouncement) {
        Date oldDateOfAnnouncement = this.dateOfAnnouncement;
        this.dateOfAnnouncement = dateOfAnnouncement;
        changeSupport.firePropertyChange("dateOfAnnouncement", oldDateOfAnnouncement, dateOfAnnouncement);
    }

    public String getHomePhone() {
        return homePhone;
    }

    public void setHomePhone(String homePhone) {
        String oldHomePhone = this.homePhone;
        this.homePhone = homePhone;
        changeSupport.firePropertyChange("homePhone", oldHomePhone, homePhone);
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        String oldMobile = this.mobile;
        this.mobile = mobile;
        changeSupport.firePropertyChange("mobile", oldMobile, mobile);
    }

    public String getEducation() {
        return education;
    }

    public void setEducation(String education) {
        String oldEducation = this.education;
        this.education = education;
        changeSupport.firePropertyChange("education", oldEducation, education);
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        String oldEmail = this.email;
        this.email = email;
        changeSupport.firePropertyChange("email", oldEmail, email);
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        String oldImagePath = this.imagePath;
        this.imagePath = imagePath;
        changeSupport.firePropertyChange("imagePath", oldImagePath, imagePath);
    }

    public List<Subvention> getSubventionList() {
        return subventionList;
    }

    public void setSubventionList(List<Subvention> subventionList) {
        this.subventionList = subventionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (memId != null ? memId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Members)) {
            return false;
        }
        Members other = (Members) object;
        if ((this.memId == null && other.memId != null) || (this.memId != null && !this.memId.equals(other.memId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "membershipdemo.Members[ memId=" + memId + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

    public String getJoiningDateFormated() {
        return KatebaUtil.convertDate(dateOfAnnouncement);
    }

    public String getHireDateFormated() {
        return KatebaUtil.convertDate(hireDate);
    }

    public String getDeductionDateFormated() {
        return KatebaUtil.convertDate(deductionDate);
    }

    public String getDateOfNatIdFormated() {
        return KatebaUtil.convertDate(dateOfNatId);
    }
    public String getDateOfBirthFormated() {
        return KatebaUtil.convertDate( dateOfBirth);
    }

}
